package com.sob.bountyhunter.entidades;

import java.util.Random;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;

import com.sob.bountyhunter.Art;
import com.sob.bountyhunter.Mapa;

public class TextoFlotante extends Entidad {

	public String texto;
	float ey;
	
	public TextoFlotante(String t, float px, float py) throws SlickException {
		super();
		texto=t;
		x=px;
		y=py-32;
		Random r=new Random();
		xvel=((float)(r.nextInt(10)-5)/100);;
		yvel=-((float)(r.nextInt(5)+30)/100);
		xinc=xvel;
		yinc=yvel;
		tieneFriccion=false;
		
		ey=y-80;		
	}

	/*
	private void creaImagen(Graphics graphics) {
		try {
			Image img=new Image(Art.defaultFont.getWidth(texto), Art.defaultFont.getHeight(texto)); //texto.length()*16, 16);
			Art.drawTextInto(texto, 0, 0, true, img, Art.defaultFont, graphics);
			
			///*
			Image img=new Image(texto.length()*16, 16);
			Graphics g=img.getGraphics();
			Graphics.setCurrent(g);
			
			g.setColor(Color.black);
			g.drawString(texto, 1, 1);
			
			g.setColor(Color.white);
			g.drawString(texto, 0, 0);
			
			Graphics.setCurrent(graphics);
			/////
			sprite=img;
		} catch (SlickException e) {
			e.printStackTrace();
		}
	}*/

	@Override
	public void render(GameContainer gameContainer, Graphics graphics, int xOff, int yOff) {		
		super.render(gameContainer, graphics, xOff, yOff);
		Art.drawText(texto, x-xOff, y-yOff, true, Art.defaultBigFont);
		
	}
	
	@Override
	public void update(GameContainer gameContainer, int deltaTime, Mapa map) {
		super.update(gameContainer, deltaTime, map);
		yinc+=0.0005*deltaTime;
		if(y>=ey && yinc>0) delete=true;
		z=999999999;
	}
}
